-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closes #296 #301
Closes #296 #301
Conversation
Thanks for the PR! It looks like the build is failing due to flake8 issues, can you run flake8 locally and sort those out? |
@justinlent Can you review this? |
@twiecki LGTM. Merge at your convenience |
@@ -57,13 +57,14 @@ def get_long_short_pos(positions): | |||
|
|||
pos_wo_cash = positions.drop('cash', axis=1) | |||
longs = pos_wo_cash[pos_wo_cash > 0].sum(axis=1).fillna(0) | |||
shorts = pos_wo_cash[pos_wo_cash < 0].abs().sum(axis=1).fillna(0) | |||
shorts = pos_wo_cash[pos_wo_cash < 0].sum(axis=1).fillna(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't removing abs()
not change the results of the plot?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it will. One of the issue tasks is to make the "shorts" line show up
as negative instead of positive.
"Make Long exposure line positive number, and Short exposure line all
negative numbers"
On Mon, May 23, 2016 at 3:34 AM, Thomas Wiecki notifications@github.com
wrote:
In pyfolio/pos.py
#301 (comment):@@ -57,13 +57,14 @@ def get_long_short_pos(positions):
pos_wo_cash = positions.drop('cash', axis=1) longs = pos_wo_cash[pos_wo_cash > 0].sum(axis=1).fillna(0)
- shorts = pos_wo_cash[pos_wo_cash < 0].abs().sum(axis=1).fillna(0)
- shorts = pos_wo_cash[pos_wo_cash < 0].sum(axis=1).fillna(0)
Won't removing abs() not change the results of the plot?
—
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
https://github.com/quantopian/pyfolio/pull/301/files/12907415ecd871a19bd60e39c35613cc13692168#r64178908
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@twiecki @ahgnaw see line 62 below where cash is added in the net_liquidation
value. I believe this results in the cash taken in from shorts being double counted. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if shorts
is a negative number, net liquidation should be longs + shorts + cash
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from our offline chat:
The explicit calculation would be net_liquidation = longs - shorts + (cash + shorts)
which removes the short exposure from the cash component
which then begs the simplification to just net_liquidation = longs + cash
where net_liquidation == portfolio_value (e.g. the amount of $ you could actually withdraw from the account)
will have to think about whether that makes sense though
Thanks @ahgnaw! |
No description provided.